package com.hunt.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.hunt.model.dto.PageInfo;
import com.hunt.model.entity.SysPermission;
import com.hunt.service.IpoStockService;
import com.hunt.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Api("板块列表")
@Controller
@RequestMapping("/ipostock")
public class IpoStockController extends BaseController{
    @Autowired
    private IpoStockService ipoStockService;

    @ApiOperation(value = "新股上会获取", httpMethod = "POST", produces = "application/json", response = Result.class)
    @ResponseBody
    @RequestMapping(value = "getIpoStock", method = RequestMethod.POST)
    public Result findipostock(@ApiParam(value = " 0是最新上会,1是最新申报,2是上会已通过,3是未上会,4是上会未通过 ")@RequestParam(value = "type", defaultValue = "0") String type, @RequestParam(value = "orderfield", defaultValue = "meetingDate")  String orderfield, @RequestParam(value = "sort", defaultValue = "1") String sort, @RequestParam(value = "position", defaultValue = "0")  String position, @RequestParam(value = "size", defaultValue = "10")  String size) {
        if ("0".equals(sort)){
            sort="asc";
        }else {
            sort="desc";
        }

        return Result.success(ipoStockService.getIpoStock(type,  orderfield,
                sort, position, size));
    }
}

